package com.xiaoxiang.auth.controller;

import com.xiaoxiang.auth.entity.User;
import com.xiaoxiang.auth.service.AuthService;
import com.xiaoxiang.common.result.HttpResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 认证控制类
 * @author: haha
 * @date: 2022/2/7 15:19
 */
@RestController
public class AuthController {


    @Resource(name = "userAuthService")
    private AuthService authService;

    /**
     * 通过用户名密码的方式登录
     */
    @PostMapping("/userPass")
    public HttpResult userPassAuth(@RequestBody User user) {
        return HttpResult.success(authService.auth(user.getUsername(), user.getPassword()));
    }

    /**
     * 验证接口
     */
    @PostMapping("/verify")
    public Boolean verify(String token, String path) {
        return authService.verify(token, path);
    }


}
